
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>View加载流程 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="事件分发机制.html" />
    
    
    <link rel="prev" href="APP的启动流程.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../doc/常用网站.html">
            
                <a href="../doc/常用网站.html">
            
                    
                    常用网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../常用软件/常用软件和框架.html">
            
                <a href="../常用软件/常用软件和框架.html">
            
                    
                    常用软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../doc/开发规范.html">
            
                <a href="../doc/开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../doc/开源软件.html">
            
                <a href="../doc/开源软件.html">
            
                    
                    开源软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../doc/Android常用代码.html">
            
                <a href="../doc/Android常用代码.html">
            
                    
                    Android常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../源码阅读/源码阅读配置.html">
            
                <a href="../源码阅读/源码阅读配置.html">
            
                    
                    源码阅读
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../源码阅读/其他框架源码.html">
            
                <a href="../源码阅读/其他框架源码.html">
            
                    
                    其他框架源码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../产品经理/产品经理.html">
            
                <a href="../产品经理/产品经理.html">
            
                    
                    产品经理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../设计模式/模式详解.html">
            
                <a href="../设计模式/模式详解.html">
            
                    
                    模式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../设计模式/mvc等.html">
            
                <a href="../设计模式/mvc等.html">
            
                    
                    mvc等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    基本算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    常用数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../常用算法/算法术语.html">
            
                <a href="../常用算法/算法术语.html">
            
                    
                    算法术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../常用算法/排序算法.html">
            
                <a href="../常用算法/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../常用算法/查找算法.html">
            
                <a href="../常用算法/查找算法.html">
            
                    
                    查找算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../常用算法/大数相加.html">
            
                <a href="../常用算法/大数相加.html">
            
                    
                    大数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../常用算法/集合的所有子集.html">
            
                <a href="../常用算法/集合的所有子集.html">
            
                    
                    获得集合的所有子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../常用算法/扫描线种子填充算法.html">
            
                <a href="../常用算法/扫描线种子填充算法.html">
            
                    
                    扫描线种子填充算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../常用算法/其他算法.html">
            
                <a href="../常用算法/其他算法.html">
            
                    
                    其他算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    Java部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    原码补码反码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../java基础/java常用代码.html">
            
                <a href="../java基础/java常用代码.html">
            
                    
                    java常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../java基础/JVM详解.html">
            
                <a href="../java基础/JVM详解.html">
            
                    
                    JVM详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../java基础/类加载机制.html">
            
                <a href="../java基础/类加载机制.html">
            
                    
                    类加载机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../java基础/内存模型.html">
            
                <a href="../java基础/内存模型.html">
            
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="../java基础/GC机制.html">
            
                <a href="../java基础/GC机制.html">
            
                    
                    GC机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="../java基础/对象内存布局.html">
            
                <a href="../java基础/对象内存布局.html">
            
                    
                    对象内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="../java基础/继承多态.html">
            
                <a href="../java基础/继承多态.html">
            
                    
                    继承和多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="../java基础/相等判断.html">
            
                <a href="../java基础/相等判断.html">
            
                    
                    相等判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="../java基础/Java容器类.html">
            
                <a href="../java基础/Java容器类.html">
            
                    
                    Java容器类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="../java基础/Java枚举.html">
            
                <a href="../java基础/Java枚举.html">
            
                    
                    Java枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="../java基础/自定义异常.html">
            
                <a href="../java基础/自定义异常.html">
            
                    
                    自定义异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="../java基础/深度拷贝.html">
            
                <a href="../java基础/深度拷贝.html">
            
                    
                    深度拷贝
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="../java基础/泛型详解.html">
            
                <a href="../java基础/泛型详解.html">
            
                    
                    泛型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="../java基础/线程详解.html">
            
                <a href="../java基础/线程详解.html">
            
                    
                    线程详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="../java基础/java注解.html">
            
                <a href="../java基础/java注解.html">
            
                    
                    注解详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="../java基础/数据解析.html">
            
                <a href="../java基础/数据解析.html">
            
                    
                    数据解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.18" data-path="../java基础/java8新特性.html">
            
                <a href="../java基础/java8新特性.html">
            
                    
                    Java8新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="android零散知识.html">
            
                <a href="android零散知识.html">
            
                    
                    Android部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="基础控件使用.html">
            
                <a href="基础控件使用.html">
            
                    
                    基础控件使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="android零散知识.html">
            
                <a href="android零散知识.html">
            
                    
                    Android零散知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="android坐标体系.html">
            
                <a href="android坐标体系.html">
            
                    
                    Android坐标体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="APP的启动流程.html">
            
                <a href="APP的启动流程.html">
            
                    
                    APP启动流程
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.12.5" data-path="View加载流程.html">
            
                <a href="View加载流程.html">
            
                    
                    View加载流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="事件分发机制.html">
            
                <a href="事件分发机制.html">
            
                    
                    事件分发机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="控件绘制流程.html">
            
                <a href="控件绘制流程.html">
            
                    
                    控件绘制流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="常用shape.html">
            
                <a href="常用shape.html">
            
                    
                    常用shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="进程通信.html">
            
                <a href="进程通信.html">
            
                    
                    进程通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../通信方式/通信方式详解.html">
            
                <a href="../通信方式/通信方式详解.html">
            
                    
                    通信方式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="Binder详解.html">
            
                <a href="Binder详解.html">
            
                    
                    Binder详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" data-path="Handler详解.html">
            
                <a href="Handler详解.html">
            
                    
                    Handle详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" data-path="Fragment详解.html">
            
                <a href="Fragment详解.html">
            
                    
                    Fragment详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" data-path="Activity详解.html">
            
                <a href="Activity详解.html">
            
                    
                    Activity详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" data-path="BroadcastReceiver.html">
            
                <a href="BroadcastReceiver.html">
            
                    
                    BroadcastReceiver详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.16" data-path="Service服务.html">
            
                <a href="Service服务.html">
            
                    
                    Service详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" data-path="动画详解.html">
            
                <a href="动画详解.html">
            
                    
                    动画详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" data-path="屏幕刷新机制.html">
            
                <a href="屏幕刷新机制.html">
            
                    
                    屏幕刷新机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" data-path="屏幕适配.html">
            
                <a href="屏幕适配.html">
            
                    
                    屏幕适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" data-path="图片加载详解.html">
            
                <a href="图片加载详解.html">
            
                    
                    图片加载详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" data-path="WebView详解.html">
            
                <a href="WebView详解.html">
            
                    
                    WebView详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" data-path="沉浸式.html">
            
                <a href="沉浸式.html">
            
                    
                    沉浸式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" data-path="相机模块.html">
            
                <a href="相机模块.html">
            
                    
                    相机模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.24" data-path="地图模块.html">
            
                <a href="地图模块.html">
            
                    
                    地图模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.25" data-path="Androidstudio插件开发.html">
            
                <a href="Androidstudio插件开发.html">
            
                    
                    Androidstudio插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.26" data-path="Apk插件化开发.html">
            
                <a href="Apk插件化开发.html">
            
                    
                    Apk插件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.27" data-path="App组件化开发.html">
            
                <a href="App组件化开发.html">
            
                    
                    App组件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.28" data-path="sdk开发.html">
            
                <a href="sdk开发.html">
            
                    
                    sdk开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.29" data-path="APP优化.html">
            
                <a href="APP优化.html">
            
                    
                    APP优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.30" data-path="项目参数配置.html">
            
                <a href="项目参数配置.html">
            
                    
                    项目参数配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.31" data-path="App发布.html">
            
                <a href="App发布.html">
            
                    
                    App发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.32" data-path="Android外挂.html">
            
                <a href="Android外挂.html">
            
                    
                    Android外挂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.33" data-path="Android字节码插桩.html">
            
                <a href="Android字节码插桩.html">
            
                    
                    Android字节码插桩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.34" data-path="智能家居.html">
            
                <a href="智能家居.html">
            
                    
                    智能家居
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../python/python爬虫.html">
            
                <a href="../python/python爬虫.html">
            
                    
                    python爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../gradle/Groovy.html">
            
                <a href="../gradle/Groovy.html">
            
                    
                    Groovy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../kotlin/kotlin部分.html">
            
                <a href="../kotlin/kotlin部分.html">
            
                    
                    kotlin部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../flutter/flutter部分.html">
            
                <a href="../flutter/flutter部分.html">
            
                    
                    flutter部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    native部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../native/Linux.html">
            
                <a href="../native/Linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    cCpp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../native/NDK.html">
            
                <a href="../native/NDK.html">
            
                    
                    NDK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../native/系统编译剪裁.html">
            
                <a href="../native/系统编译剪裁.html">
            
                    
                    系统编译剪裁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../native/音视频.html">
            
                <a href="../native/音视频.html">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../native/音视频第三方库.html">
            
                <a href="../native/音视频第三方库.html">
            
                    
                    音视频第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../native/相关代码.html">
            
                <a href="../native/相关代码.html">
            
                    
                    相关代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../server/服务器部分.html">
            
                <a href="../server/服务器部分.html">
            
                    
                    服务器部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../webDev/web部分.html">
            
                <a href="../webDev/web部分.html">
            
                    
                    web部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../人工智能/人工智能相关概念.html">
            
                <a href="../人工智能/人工智能相关概念.html">
            
                    
                    人工智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../面试真题/极飞.html">
            
                <a href="../面试真题/极飞.html">
            
                    
                    面试真题
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >View加载流程</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x76F8;&#x5173;&#x7C7B;"><b>1. </b>&#x76F8;&#x5173;&#x7C7B;</a></li><ul><li><span class="title-icon "></span><a href="#windowjava&#x3001;phonewindowjava"><b>1.1. </b>Window.java&#x3001;PhoneWindow.java</a></li><li><span class="title-icon "></span><a href="#windowmanagerjava--interface-"><b>1.2. </b>WindowManager.java ( interface )</a></li><li><span class="title-icon "></span><a href="#windowmanagerimpljava--class-"><b>1.3. </b>WindowManagerImpl.java ( class )</a></li><li><span class="title-icon "></span><a href="#windowmanagerglobaljava-&#x5355;&#x4F8B;"><b>1.4. </b>WindowManagerGlobal.java (&#x5355;&#x4F8B;)</a></li><li><span class="title-icon "></span><a href="#windowmanagerservicejava"><b>1.5. </b>WindowManagerService.java</a></li><li><span class="title-icon "></span><a href="#surfaceflingercpp"><b>1.6. </b>SurfaceFlinger.cpp</a></li><li><span class="title-icon "></span><a href="#decorviewjava"><b>1.7. </b>DecorView.java</a></li><li><span class="title-icon "></span><a href="#activityjava"><b>1.8. </b>Activity.java</a></li><li><span class="title-icon "></span><a href="#viewrootimpljava-&#x3001;viewroot&#x5DF2;&#x7ECF;&#x5E9F;&#x5F03;"><b>1.9. </b>ViewRootImpl.java &#x3001;ViewRoot(&#x5DF2;&#x7ECF;&#x5E9F;&#x5F03;)</a></li><li><span class="title-icon "></span><a href="#viewmanagerjava-&#x63A5;&#x53E3;"><b>1.10. </b>ViewManager.java &#x63A5;&#x53E3;</a></li><li><span class="title-icon "></span><a href="#&#x5173;&#x7CFB;&#x56FE;"><b>1.11. </b>&#x5173;&#x7CFB;&#x56FE;</a></li></ul><li><span class="title-icon "></span><a href="#&#x603B;&#x7ED3;"><b>2. </b>&#x603B;&#x7ED3;</a></li><li><span class="title-icon "></span><a href="#&#x63D0;&#x95EE;"><b>3. </b>&#x63D0;&#x95EE;</a></li><ul><li><span class="title-icon "></span><a href="#activity&#x3001;window&#x3001;viewrootimpl&#x3001;decorview&#x4E4B;&#x95F4;&#x7684;&#x8054;&#x7CFB;"><b>3.1. </b>Activity&#x3001;Window&#x3001;ViewRootImpl&#x3001;DecorView&#x4E4B;&#x95F4;&#x7684;&#x8054;&#x7CFB;</a></li><li><span class="title-icon "></span><a href="#activity-&#x6709;&#x51E0;&#x4E2A;-phonewindow-window"><b>3.2. </b>Activity &#x6709;&#x51E0;&#x4E2A; PhoneWindow (Window)</a></li><li><span class="title-icon "></span><a href="#phonewindow-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><b>3.3. </b>PhoneWindow &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</a></li><li><span class="title-icon "></span><a href="#viewrootimpl-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><b>3.4. </b>ViewRootImpl &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</a></li><li><span class="title-icon "></span><a href="#activity-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><b>3.5. </b>Activity &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</a></li><li><span class="title-icon "></span><a href="#decorview-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><b>3.6. </b>DecorView &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</a></li><li><span class="title-icon "></span><a href="#&#x9664;&#x4E86;-activity-&#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x65B9;&#x5F0F;&#x663E;&#x793A;-window"><b>3.7. </b>&#x9664;&#x4E86; Activity &#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x65B9;&#x5F0F;&#x663E;&#x793A; Window</a></li><li><span class="title-icon "></span><a href="#setcontentview&#x540E;&#x7684;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;"><b>3.8. </b>setContentView()&#x540E;&#x7684;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;</a></li><li><span class="title-icon "></span><a href="#setcontentview-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;"><b>3.9. </b>setContentView &#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230; Activity&#x4E2D;&#x7684;</a></li><li><span class="title-icon "></span><a href="#layoutinflater-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;"><b>3.10. </b>LayoutInflater &#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230; Activity&#x4E2D;&#x7684;</a></li></ul><li><span class="title-icon "></span><a href="#viewgroup-&#x76F8;&#x5173;&#x65B9;&#x6CD5;"><b>4. </b>ViewGroup &#x76F8;&#x5173;&#x65B9;&#x6CD5;</a></li><ul><li><span class="title-icon "></span><a href="#checklayoutparams"><b>4.1. </b>checkLayoutParams()</a></li><li><span class="title-icon "></span><a href="#generatedefaultlayoutparams"><b>4.2. </b>generateDefaultLayoutParams()</a></li><li><span class="title-icon "></span><a href="#generatelayoutparams"><b>4.3. </b>generateLayoutParams()</a></li></ul></ul></div><a href="#&#x76F8;&#x5173;&#x7C7B;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x76F8;&#x5173;&#x7C7B;"><a name="&#x76F8;&#x5173;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#&#x76F8;&#x5173;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x76F8;&#x5173;&#x7C7B;</h1>
<h2 id="windowjava&#x3001;phonewindowjava"><a name="windowjava&#x3001;phonewindowjava" class="anchor-navigation-ex-anchor" href="#windowjava&#x3001;phonewindowjava"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. Window.java&#x3001;PhoneWindow.java</h2>
<pre><code class="lang-text">Window &#x662F;&#x62BD;&#x8C61;&#x7C7B;&#xFF0C;&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x7A97;&#x53E3;&#x7684;&#x6982;&#x5FF5;&#x3002;Window&#x662F;&#x6240;&#x6709;&#x89C6;&#x56FE;&#x7684;&#x8F7D;&#x4F53;&#x3002;

PhoneWindow &#x4E2D;&#x6709;&#x4E2A;&#x5185;&#x90E8;&#x5C5E;&#x6027; DecorView &#xFF0C;
&#x901A;&#x8FC7;&#x521B;&#x5EFA; DecorView &#x6765;&#x52A0;&#x8F7D; Activity &#x4E2D;&#x8BBE;&#x7F6E;&#x7684;&#x5E03;&#x5C40; R.layout.xxx ,

PhoneWindow &#x662F; Window &#x7684;&#x552F;&#x4E00;&#x5B9E;&#x73B0;&#x7C7B;&#xFF0C;
PhoneWindow &#x901A;&#x8FC7; Activity &#x53BB;&#x63A7;&#x5236; View &#x3002;

&#x5F53;&#x6211;&#x4EEC;&#x8C03;&#x7528; Activity &#x7684; setContentView() &#x65F6;&#xFF0C;&#x5176;&#x5B9E;&#x6700;&#x7EC8;&#x4F1A;&#x8C03;&#x7528;Window&#x7684;setContentView()&#xFF0C;
&#x5F53;&#x6211;&#x4EEC;&#x8C03;&#x7528; Activity &#x7684; findViewById()&#x65F6;&#xFF0C;&#x5176;&#x5B9E;&#x6700;&#x7EC8;&#x8C03;&#x7528;&#x7684;&#x662F;Window&#x7684;findViewById()&#xFF0C;
&#x8FD9;&#x8BF4;&#x660E;&#x4E86; Window &#x662F; View &#x7684;&#x7BA1;&#x7406;&#x8005;&#x3002;
</code></pre>
<h2 id="windowmanagerjava--interface-"><a name="windowmanagerjava--interface-" class="anchor-navigation-ex-anchor" href="#windowmanagerjava--interface-"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. WindowManager.java ( interface )</h2>
<pre><code class="lang-text">WindowManager &#x662F;&#x5916;&#x754C;&#x8BBF;&#x95EE;Window&#x7684;&#x5165;&#x53E3; ,
WindowManager &#x7684;&#x4E3B;&#x8981;&#x529F;&#x80FD;&#x662F;&#x63D0;&#x4F9B;&#x7B80;&#x5355;&#x7684;API&#x4F7F;&#x5F97;&#x4F7F;&#x7528;&#x8005;&#x53EF;&#x4EE5;&#x65B9;&#x4FBF;&#x5730;&#x5C06;&#x4E00;&#x4E2A;&#x63A7;&#x4EF6;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x7A97;&#x53E3;&#x6DFB;&#x52A0;&#x5230;&#x7CFB;&#x7EDF;&#x4E2D;&#xFF0C;
&#x4F7F;&#x5F97;&#x5F00;&#x53D1;&#x8005;&#x65E0;&#x9700;&#x5173;&#x6CE8;&#x4E0E;WMS&#x590D;&#x6742;&#x7684;&#x901A;&#x4FE1;&#x8FC7;&#x7A0B;&#xFF0C;
&#x901A;&#x8FC7;WindowManager&#x5373;&#x53EF;&#x7B80;&#x5355;&#x7684;&#x6DFB;&#x52A0;&#x5220;&#x9664;&#x7A97;&#x53E3;&#x3002;

&#x800C; WindowManager &#x901A;&#x8FC7; Binder &#x673A;&#x5236;&#x4E0E; WindowManagerService &#x8FDB;&#x884C;&#x8DE8;&#x8FDB;&#x7A0B;&#x901A;&#x4FE1;&#xFF0C;
&#x6700;&#x7EC8;&#x628A;&#x5177;&#x4F53;&#x7684;&#x5B9E;&#x73B0;&#x5DE5;&#x4F5C;&#x4EA4;&#x7ED9; WindowManagerService&#x3002;
</code></pre>
<h2 id="windowmanagerimpljava--class-"><a name="windowmanagerimpljava--class-" class="anchor-navigation-ex-anchor" href="#windowmanagerimpljava--class-"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. WindowManagerImpl.java ( class )</h2>
<pre><code class="lang-text">private final WindowManagerGlobal mGlobal; // &#x5B9E;&#x9645;&#x5B9E;&#x73B0;&#x8005;
private final Display mDisplay; //&#x4FDD;&#x5B58;&#x6240;&#x5C5E;&#x5C4F;&#x5E55;
private final Window mParentWindow; // &#x7A97;&#x53E3;
</code></pre>
<h2 id="windowmanagerglobaljava-&#x5355;&#x4F8B;"><a name="windowmanagerglobaljava-&#x5355;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#windowmanagerglobaljava-&#x5355;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. WindowManagerGlobal.java (&#x5355;&#x4F8B;)</h2>
<pre><code class="lang-text">IWindowSession sWindowSession ;// aidl ,&#x4E0E; WMS
ArrayList&lt;ViewRootImpl&gt; mRoots // &#x6839;View &#x7684;&#x7BA1;&#x7406;&#x8005;
IWindowManager sWindowManagerService // adil ,WMS &#x5728; client &#x7684;&#x4EE3;&#x7406;
ArrayList&lt;View&gt; mViews // &#x6240;&#x6709;&#x7A97;&#x53E3;&#x7684;&#x6839;View ( &#x5373;DecorView)
ArrayList&lt;LayoutParams&gt; mParams //&#x5E03;&#x5C40;&#x53C2;&#x6570;
</code></pre>
<h2 id="windowmanagerservicejava"><a name="windowmanagerservicejava" class="anchor-navigation-ex-anchor" href="#windowmanagerservicejava"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. WindowManagerService.java</h2>
<pre><code class="lang-text">WMS &#x8FD0;&#x884C;&#x5728; system_server &#x8FDB;&#x7A0B;&#x4E2D; &#xFF0C;
android &#x7684;&#x7A97;&#x53E3;&#x7BA1;&#x7406;&#x670D;&#x52A1; &#xFF0C;
&#x8981;&#x5904;&#x7406;&#x5BF9;&#x8F93;&#x5165;&#x4E8B;&#x4EF6;&#x7684;&#x6D3E;&#x53D1;&#x3001;
&#x8D1F;&#x8D23;&#x7BA1;&#x7406;&#x7A97;&#x53E3; Surface &#x7684;&#x5E03;&#x5C40;&#x7B49;&#x5177;&#x4F53;&#x5DE5;&#x4F5C;&#x3002;
</code></pre>
<h2 id="surfaceflingercpp"><a name="surfaceflingercpp" class="anchor-navigation-ex-anchor" href="#surfaceflingercpp"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. SurfaceFlinger.cpp</h2>
<pre><code class="lang-text">SurfaceFlinger &#x5C06; WMS &#x7EF4;&#x62A4;&#x7684;&#x7A97;&#x53E3; Surface &#x663E;&#x793A;&#x5230; &#x5C4F;&#x5E55;&#x4E0A;&#x3002;
&#x57FA;&#x672C;&#x53EA;&#x505A;&#x4E0E;&#x201C;&#x663E;&#x793A;&#x201D;&#x76F8;&#x5173;&#x7684;&#x4E8B;&#x60C5; &#x3002;
</code></pre>
<h2 id="decorviewjava"><a name="decorviewjava" class="anchor-navigation-ex-anchor" href="#decorviewjava"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. DecorView.java</h2>
<pre><code class="lang-text"> DecorView extends FrameLayout 
 DecorView &#x662F;&#x6574;&#x4E2A; Window &#x754C;&#x9762;&#x7684;&#x6700;&#x9876;&#x5C42; View&#x3002;

&#x53EF;&#x4EE5;&#x7528; Androidstudio &#x7684;&#x5DE5;&#x5177;&#x67E5;&#x770B; DecorView&#x7684;&#x5E03;&#x5C40;&#x3002;
Tools -&gt; Layout Inspector
</code></pre>
<p> <img src="../pics/DecorView&#x7ED3;&#x6784;.png" alt=""></p>
<h2 id="activityjava"><a name="activityjava" class="anchor-navigation-ex-anchor" href="#activityjava"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. Activity.java</h2>
<pre><code class="lang-text"> Activity &#x5E76;&#x4E0D;&#x8D1F;&#x8D23;&#x89C6;&#x56FE;&#x63A7;&#x5236;&#xFF0C;&#x5B83;&#x53EA;&#x662F;&#x63A7;&#x5236;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x5904;&#x7406;&#x4E8B;&#x4EF6;&#x3002;
 &#x771F;&#x6B63;&#x63A7;&#x5236;&#x89C6;&#x56FE;&#x7684;&#x662F;Window&#x3002; Window &#x901A;&#x8FC7; Activity &#x64CD;&#x4F5C; View &#x3002;
 &#x4E00;&#x4E2A; Activity&#x5305;&#x542B;&#x548C;&#x7EF4;&#x62A4;&#x7740;&#x4E00;&#x4E2A; Window &#x5BF9;&#x8C61; &#xFF0C;Window&#x624D;&#x662F;&#x771F;&#x6B63;&#x4EE3;&#x8868;&#x4E00;&#x4E2A;&#x7A97;&#x53E3;&#x3002;
</code></pre>
<h2 id="viewrootimpljava-&#x3001;viewroot&#x5DF2;&#x7ECF;&#x5E9F;&#x5F03;"><a name="viewrootimpljava-&#x3001;viewroot&#x5DF2;&#x7ECF;&#x5E9F;&#x5F03;" class="anchor-navigation-ex-anchor" href="#viewrootimpljava-&#x3001;viewroot&#x5DF2;&#x7ECF;&#x5E9F;&#x5F03;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. ViewRootImpl.java &#x3001;ViewRoot(&#x5DF2;&#x7ECF;&#x5E9F;&#x5F03;)</h2>
<pre><code class="lang-text">&#x4ECE;&#x5B57;&#x9762;&#x4E0A;&#x6765;&#x770B; ViewRootImpl &#x662F; ViewRoot &#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x5176;&#x5B9E;&#x4E0D;&#x662F;&#x7684;&#x3002;
Android 2.2 &#x4E2D; ViewRoot &#x88AB;&#x5E9F;&#x5F03;&#xFF0C;&#x7531; ViewRootImpl &#x66FF;&#x4EE3;&#x4E86;&#x3002;

PhoneWindow &#x901A;&#x8FC7; WindowManager &#x5C06; DecorView &#x52A0;&#x8F7D;&#x5176;&#x4E2D;&#xFF0C;&#x5E76;&#x5C06; DecorView &#x4EA4;&#x7ED9; ViewRootImpl &#xFF0C;
ViewRootImpl &#x4F5C;&#x4E3A; &#x8FDE;&#x63A5;&#x5668;&#xFF0C;&#x8FDE;&#x63A5; DecorView &#x4E0E; WMS&#xFF0C;&#x8D1F;&#x8D23;&#x4E0E; WMS &#x8FDB;&#x884C;&#x76F4;&#x63A5;&#x7684;&#x901A;&#x8BAF; &#x3002;

ViewRootImpl &#x8D1F;&#x8D23;&#x4E0E; WMS &#x8FDB;&#x884C;&#x76F4;&#x63A5;&#x7684;&#x901A;&#x8BAF;&#xFF0C;
&#x8D1F;&#x8D23;&#x7BA1;&#x7406;Surface&#xFF0C;
&#x8D1F;&#x8D23;&#x89E6;&#x53D1;View&#x7684;&#x6D4B;&#x91CF;&#x3001;&#x5E03;&#x5C40;&#x3001;&#x7ED8;&#x5236;&#xFF0C;
&#x540C;&#x65F6;&#x4E5F;&#x662F;&#x8F93;&#x5165;&#x4E8B;&#x4EF6;&#x7684;&#x4E2D;&#x8F6C;&#x7AD9;&#xFF0C;

&#x8F93;&#x5165;&#x4E8B;&#x4EF6;&#x7684;&#x6D3E;&#x53D1;&#x5904;&#x7406;&#x90FD;&#x7531;ViewRootImpl&#x89E6;&#x53D1;&#x3002;
&#x5B83;&#x662F;WindowManagerGlobal&#x5DE5;&#x4F5C;&#x7684;&#x5B9E;&#x9645;&#x5B9E;&#x73B0;&#x8005;&#xFF0C;
&#x5B83;&#x9700;&#x8981;&#x8D1F;&#x8D23;&#x4E0E;WMS&#x4EA4;&#x4E92;&#x901A;&#x4FE1;&#x4EE5;&#x8C03;&#x6574;&#x7A97;&#x53E3;&#x7684;&#x4F4D;&#x7F6E;&#x5927;&#x5C0F;&#xFF0C;
&#x4EE5;&#x53CA;&#x5BF9;&#x6765;&#x81EA;WMS&#x7684;&#x4E8B;&#x4EF6;&#xFF08;&#x5982;&#x7A97;&#x53E3;&#x5C3A;&#x5BF8;&#x6539;&#x53D8;&#x7B49;&#xFF09;&#x4F5C;&#x51FA;&#x76F8;&#x5E94;&#x7684;&#x5904;&#x7406;&#x3002;
&#x603B;&#x4E4B;&#xFF0C;ViewRootImpl&#x662F;&#x6574;&#x4E2A;&#x63A7;&#x4EF6;&#x7CFB;&#x7EDF;&#x6B63;&#x5E38;&#x8FD0;&#x8F6C;&#x7684;&#x52A8;&#x529B;&#x6240;&#x5728; &#x3002;
</code></pre>
<h2 id="viewmanagerjava-&#x63A5;&#x53E3;"><a name="viewmanagerjava-&#x63A5;&#x53E3;" class="anchor-navigation-ex-anchor" href="#viewmanagerjava-&#x63A5;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.10. ViewManager.java &#x63A5;&#x53E3;</h2>
<pre><code class="lang-text">&#x662F;&#x4E00;&#x4E2A;&#x529F;&#x80FD;&#x63A5;&#x53E3;&#xFF0C;&#x5B9A;&#x4E49;&#x4E86;&#x589E;&#x3001;&#x5220;&#x3001;&#x66F4;&#x65B0; View&#x7684;&#x80FD;&#x529B;&#x3002;
void addView(xx);
void updateViewLayout(xx);
void removeView(xx);
</code></pre>
<h2 id="&#x5173;&#x7CFB;&#x56FE;"><a name="&#x5173;&#x7CFB;&#x56FE;" class="anchor-navigation-ex-anchor" href="#&#x5173;&#x7CFB;&#x56FE;"><i class="fa fa-link" aria-hidden="true"></i></a>1.11. &#x5173;&#x7CFB;&#x56FE;</h2>
<p><img src="../pics/View&#x7B49;&#x5173;&#x7CFB;&#x56FE;.png" alt=""></p>
<h1 id="&#x603B;&#x7ED3;"><a name="&#x603B;&#x7ED3;" class="anchor-navigation-ex-anchor" href="#&#x603B;&#x7ED3;"><i class="fa fa-link" aria-hidden="true"></i></a>2. &#x603B;&#x7ED3;</h1>
<pre><code class="lang-text">Window &#x662F; View &#x7684;&#x8F7D;&#x4F53;&#xFF0C;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x5BF9;Window&#x8FDB;&#x884C;&#x5220;&#x9664;&#xFF0C;&#x6DFB;&#x52A0;&#xFF0C;&#x66F4;&#x65B0; View &#x5C31;&#x5F97;&#x901A;&#x8FC7; WindowManager &#xFF0C;
WindowManager &#x4E0E; WindowManagerService &#x901A;&#x8FC7; Session &#x8FDB;&#x884C;&#x901A;&#x4FE1;&#xFF0C;&#x5177;&#x4F53;&#x7684;&#x5B9E;&#x73B0;&#x5C31;&#x4EA4;&#x7ED9;&#x4E86; WindowManagerService &#x5904;&#x7406;&#xFF0C;
WindowManagerService &#x4F1A;&#x4E3A;&#x6BCF;&#x4E00;&#x4E2A; Window &#x521B;&#x5EFA;&#x4E00;&#x4E2A; WindowState &#x5E76;&#x7BA1;&#x7406;&#x5B83;&#x4EEC;&#xFF0C;
&#x5177;&#x4F53;&#x7684;&#x6E32;&#x67D3;&#x5DE5;&#x4F5C; WindowManagerService &#x5C31;&#x4EA4;&#x7ED9; SurfaceFlinger &#x5904;&#x7406;&#x3002;
</code></pre>
<h1 id="&#x63D0;&#x95EE;"><a name="&#x63D0;&#x95EE;" class="anchor-navigation-ex-anchor" href="#&#x63D0;&#x95EE;"><i class="fa fa-link" aria-hidden="true"></i></a>3. &#x63D0;&#x95EE;</h1>
<h2 id="activity&#x3001;window&#x3001;viewrootimpl&#x3001;decorview&#x4E4B;&#x95F4;&#x7684;&#x8054;&#x7CFB;"><a name="activity&#x3001;window&#x3001;viewrootimpl&#x3001;decorview&#x4E4B;&#x95F4;&#x7684;&#x8054;&#x7CFB;" class="anchor-navigation-ex-anchor" href="#activity&#x3001;window&#x3001;viewrootimpl&#x3001;decorview&#x4E4B;&#x95F4;&#x7684;&#x8054;&#x7CFB;"><i class="fa fa-link" aria-hidden="true"></i></a>3.1. Activity&#x3001;Window&#x3001;ViewRootImpl&#x3001;DecorView&#x4E4B;&#x95F4;&#x7684;&#x8054;&#x7CFB;</h2>
<pre><code class="lang-text">Activity &#x4E2D;&#x5305;&#x542B;&#x4E00;&#x4E2A; Window ,Window&#x4E2D;&#x5305;&#x542B;&#x4E00;&#x4E2A;DecorView &#x3002;
MainActivity.this.getWindow() .getDecorView();
&#x5176;&#x4ED6;&#x7684;&#x8BF7;&#x53C2;&#x770B;&#x4E0A;&#x9762;&#x7684;&#x5173;&#x7CFB;&#x56FE;&#x3002;
</code></pre>
<h2 id="activity-&#x6709;&#x51E0;&#x4E2A;-phonewindow-window"><a name="activity-&#x6709;&#x51E0;&#x4E2A;-phonewindow-window" class="anchor-navigation-ex-anchor" href="#activity-&#x6709;&#x51E0;&#x4E2A;-phonewindow-window"><i class="fa fa-link" aria-hidden="true"></i></a>3.2. Activity &#x6709;&#x51E0;&#x4E2A; PhoneWindow (Window)</h2>
<pre><code class="lang-text">&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x3002;&#x5728; Activit.java &#x4E2D;&#x7684; attach()&#x4E2D;&#x521B;&#x5EFA; .
</code></pre>
<h2 id="phonewindow-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><a name="phonewindow-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;" class="anchor-navigation-ex-anchor" href="#phonewindow-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><i class="fa fa-link" aria-hidden="true"></i></a>3.3. PhoneWindow &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</h2>
<pre><code class="lang-text">&#x5728; Activit.java &#x4E2D;&#x7684; attach()&#x4E2D;&#x521B;&#x5EFA; .
final void attach( xxx) {
        attachBaseContext(context);
        mWindow = new PhoneWindow(this, window, activityConfigCallback);
        mWindow.setWindowControllerCallback(this);
}
</code></pre>
<h2 id="viewrootimpl-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><a name="viewrootimpl-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;" class="anchor-navigation-ex-anchor" href="#viewrootimpl-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><i class="fa fa-link" aria-hidden="true"></i></a>3.4. ViewRootImpl &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</h2>
<pre><code class="lang-text">&#x7528;&#x6237;&#x5728; &#x6DFB;&#x52A0; View&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6700;&#x7EC8;&#x4F1A; &#x8DF3;&#x8F6C;&#x5230; WindowManagerGlobal &#x7684; addView(xx) ,
&#x5728;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x4E2D; ViewRootImpl &#x88AB;&#x521B;&#x5EFA;
ViewRootImpl root = new ViewRootImpl(view.getContext(), display);
view.setLayoutParams(wparams);
this.mRoots.add(root); // ArrayList&lt;ViewRootImpl&gt; mRoots = new ArrayList();
</code></pre>
<h2 id="activity-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><a name="activity-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;" class="anchor-navigation-ex-anchor" href="#activity-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><i class="fa fa-link" aria-hidden="true"></i></a>3.5. Activity &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</h2>
<pre><code class="lang-text">&#x5728; ActivityThread &#x7684; performLaunchActivity( ...) &#x4E2D;&#x88AB;&#x521B;&#x5EFA; &#x3002; 
ClassLoader cl = r.packageInfo.getClassLoader();
activity = this.mInstrumentation.newActivity(cl, component.getClassName(), r.intent);
</code></pre>
<h2 id="decorview-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><a name="decorview-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;" class="anchor-navigation-ex-anchor" href="#decorview-&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;"><i class="fa fa-link" aria-hidden="true"></i></a>3.6. DecorView &#x521B;&#x5EFA;&#x7684;&#x65F6;&#x673A;</h2>
<pre><code class="lang-text">&#x5728; PhoneWindow &#x7684; setContentView(...) &#x65F6;&#x4F1A;&#x8FDB;&#x884C;&#x4E00;&#x7CFB;&#x5217;&#x7684;&#x5224;&#x65AD;&#xFF0C;
&#x5176;&#x4E2D;&#x4F1A; &#x5BF9; mDecor &#x8FDB;&#x884C;&#x5224;&#x65AD; &#xFF0C;&#x5982;&#x679C;&#x4E3A;&#x7A7A; &#x5C31;&#x4F1A;&#x8FDB;&#x884C;&#x65B0;&#x5EFA;&#x3002;
return new DecorView(context, featureId, this, getAttributes());
</code></pre>
<h2 id="&#x9664;&#x4E86;-activity-&#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x65B9;&#x5F0F;&#x663E;&#x793A;-window"><a name="&#x9664;&#x4E86;-activity-&#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x65B9;&#x5F0F;&#x663E;&#x793A;-window" class="anchor-navigation-ex-anchor" href="#&#x9664;&#x4E86;-activity-&#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x65B9;&#x5F0F;&#x663E;&#x793A;-window"><i class="fa fa-link" aria-hidden="true"></i></a>3.7. &#x9664;&#x4E86; Activity &#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x65B9;&#x5F0F;&#x663E;&#x793A; Window</h2>
<pre><code class="lang-text">1&#x3001;Dialog
Dialog implements  Window.Callback, , Window.OnWindowDismissedCallback ... 
Dialog( Context context, int themeResId, xx) {
    ...
    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final Window w = new PhoneWindow(mContext);
    mWindow = w;
}
</code></pre>
<h2 id="setcontentview&#x540E;&#x7684;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;"><a name="setcontentview&#x540E;&#x7684;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#setcontentview&#x540E;&#x7684;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>3.8. setContentView()&#x540E;&#x7684;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;</h2>
<p>&#x4E00;&#x8DEF;&#x8FFD;&#x8E2A;&#x6E90;&#x7801;&#xFF0C;&#x53D1;&#x73B0;&#x7528;&#x6237;&#x7684;view&#x662F;&#x88AB;&#x6DFB;&#x52A0;&#x5230;mContentParent&#x4E2D;&#x3002;</p>
<pre><code class="lang-text">ViewGroup  mContentParent = generateLayout(mDecor);
ViewGroup contentParent = (ViewGroup)findViewById(ID_ANDROID_CONTENT);
public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content;
</code></pre>
<h2 id="setcontentview-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;"><a name="setcontentview-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;" class="anchor-navigation-ex-anchor" href="#setcontentview-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;"><i class="fa fa-link" aria-hidden="true"></i></a>3.9. setContentView &#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230; Activity&#x4E2D;&#x7684;</h2>
<pre><code class="lang-text">setContentView(R.layout.activity_main)
&#x5C06;&#x5E03;&#x5C40;&#x6587;&#x4EF6;&#x4EA4;&#x7ED9; PhoneWindow &#xFF0C;
1&#x3001;PhoneWindow &#x4F1A;&#x5B9E;&#x4F8B;&#x5316;&#x4E00;&#x4E2A; DecorView(&#x8FD9;&#x662F;&#x6BCF;&#x4E2A;Activity&#x6839;&#x5E03;&#x5C40;)&#x5F80;&#x8FD9;&#x4E2A;&#x5E03;&#x5C40;&#x91CC;&#x6DFB;&#x52A0;&#x4E86;&#x4E00;&#x4E2A; LinearLayout

2&#x3001;PhoneWindow &#x6700;&#x7EC8;&#x4EA4;&#x7ED9; LayoutInflater &#x53BB;&#x5904;&#x7406; &#xFF0C;&#x83B7;&#x5F97;&#x4E00;&#x4E2A; Viwe (&#x4F1A;&#x88AB;&#x653E;&#x5230; DecorView&#x4E2D;)&#x3002;
&#x5148;&#x521B;&#x5EFA;&#x6700;&#x5916;&#x5C42;&#x7684; View
 // Temp is the root view that was found in the xml
final View temp = createViewFromTag(root, name, inflaterContext, attrs);
&#x7136;&#x540E;&#x7528;&#x53CD;&#x5C04;&#x7684;&#x65B9;&#x5F0F; &#x83B7;&#x5F97;&#x5B50;View &#xFF0C;&#x5E76;&#x6DFB;&#x52A0;&#x5230; temp &#x3002;

3&#x3001;PhoneWindow &#x7528; Callback &#x901A;&#x77E5;&#x5237;&#x65B0; UI
final Callback cb = getCallback();
cb.onContentChanged();
</code></pre>
<p><img src="../pics/&#x5E03;&#x5C40;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;.png" alt=""></p>
<h2 id="layoutinflater-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;"><a name="layoutinflater-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;" class="anchor-navigation-ex-anchor" href="#layoutinflater-&#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230;-activity&#x4E2D;&#x7684;"><i class="fa fa-link" aria-hidden="true"></i></a>3.10. LayoutInflater &#x5982;&#x4F55;&#x628A;xml&#x6587;&#x4EF6;&#x663E;&#x793A;&#x5230; Activity&#x4E2D;&#x7684;</h2>
<pre><code class="lang-text">LayoutInflater inflater = (LayoutInflater) mCtx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootView = inflater.inflate(R.layout.lonlatinputwindow, null);
this.setContentView(rootView);

&#x5177;&#x4F53;&#x6D41;&#x7A0B;&#x53C2;&#x770B; setContentView &#x7684;&#x6D41;&#x7A0B;&#x3002;
</code></pre>
<h1 id="viewgroup-&#x76F8;&#x5173;&#x65B9;&#x6CD5;"><a name="viewgroup-&#x76F8;&#x5173;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#viewgroup-&#x76F8;&#x5173;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>4. ViewGroup &#x76F8;&#x5173;&#x65B9;&#x6CD5;</h1>
<h2 id="checklayoutparams"><a name="checklayoutparams" class="anchor-navigation-ex-anchor" href="#checklayoutparams"><i class="fa fa-link" aria-hidden="true"></i></a>4.1. checkLayoutParams()</h2>
<pre><code class="lang-text">&#x7528;&#x6765;&#x68C0;&#x67E5;&#x4F60;&#x7684; LayoutParams &#x662F;&#x5426;&#x662F;&#x6B63;&#x786E;&#x3002;
@Override
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
    return new SecondaryScreenView.LayoutParams(p);
}
</code></pre>
<h2 id="generatedefaultlayoutparams"><a name="generatedefaultlayoutparams" class="anchor-navigation-ex-anchor" href="#generatedefaultlayoutparams"><i class="fa fa-link" aria-hidden="true"></i></a>4.2. generateDefaultLayoutParams()</h2>
<pre><code class="lang-text">&#x83B7;&#x53D6;&#x9ED8;&#x8BA4;&#x7684;  LayoutParams
</code></pre>
<h2 id="generatelayoutparams"><a name="generatelayoutparams" class="anchor-navigation-ex-anchor" href="#generatelayoutparams"><i class="fa fa-link" aria-hidden="true"></i></a>4.3. generateLayoutParams()</h2>
<pre><code class="lang-text">//ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
&#x4ECE; xml &#x83B7;&#x5F97;&#x7684; LayoutParams

//ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
if (!checkLayoutParams(params)) {
   params = generateLayoutParams(params);
}
When a ViewGroup is passed a View whose layout params do not pass the test of
checkLayoutParams(android.view.ViewGroup.LayoutParams ) , this method is invoked.
</code></pre>
<footer class="page-footer"><span class="copyright">( no Copyright&#xFF0C;enjoy youself ! ) all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">The file was updated at :
2022-04-04 10:49:02
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="APP的启动流程.html" class="navigation navigation-prev " aria-label="Previous page: APP启动流程">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="事件分发机制.html" class="navigation navigation-next " aria-label="Next page: 事件分发机制">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"View加载流程","level":"1.12.5","depth":2,"next":{"title":"事件分发机制","level":"1.12.6","depth":2,"path":"chinese/android基础/事件分发机制.md","ref":"chinese/android基础/事件分发机制.md","articles":[]},"previous":{"title":"APP启动流程","level":"1.12.4","depth":2,"path":"chinese/android基础/APP的启动流程.md","ref":"chinese/android基础/APP的启动流程.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","local-video","splitter","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"( no Copyright，enjoy youself ! )","modify_label":"The file was updated at :","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/android基础/View加载流程.md","mtime":"2022-04-04T02:49:02.749Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-04-04T03:47:09.782Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

